//specification file for the board class
#include <iostream>
#include "board.h"

using namespace std;

board::board()
{ //default constructor for a game with 6 rows and 7 columns
	row = 6;
	col = 7;
	field = new int*[row];
	for (int i = 0; i < row; i++) //creates dynamic 2d array
		field[i] = new int[col];

	for (int a = 0; a < row; a++) //initializes to 0
		for (int l = 0; l < (col); l++)
			field[a][l] = 0;	
}

board::board(int rows, int cols)
{ //nondefault constructor for user defined size games. Currently incomplete

}

board::board(board& b)
{ //copy constructor
	row = b.col;
	col = b.col;

	field = new int*[row];
	for (int i = 0; i < row; i++)
		field[i] = new int[col];

	for (int r = 0; r < row; r++)
		for (int c = 0; c < col; c++)
			field[r][c] = b.field[r][c];
}

board::~board()
{ //destructor
	for (int i = 0; i < row; i++)
		delete [] field[i];
	delete [] field;
}

void board::printboard()
{ //prints out the board
	cout<<"---------------\n" <<"|1|2|3|4|5|6|7|\n" <<"---------------\n";
	for (int i = 0; i < row; i++)
	{
		cout<<"|";
		for (int j = 0; j < col; j++)
		{
			if (field[i][j] == 0)
				cout<< " |"; //0 is the default, just an empty space on the board
			else
				cout<< field[i][j] <<"|"; //if it isn't one of those, it's a player token
			//players are stored as 1 or 2, so that number is output as is
		}
		cout<< endl <<"---------------\n";
	} 
}

void board::printboard(int** currentField)
{ //prints out the board
	cout<<"---------------\n" <<"|1|2|3|4|5|6|7|\n" <<"---------------\n";
	for (int i = 0; i < row; i++)
	{
		cout<<"|";
		for (int j = 0; j < col; j++)
		{
			if (currentField[i][j] == 0)
				cout<< " |"; //0 is the default, just an empty space on the board
			else if (currentField[i][j] == 1)
				cout << (char)1 <<"|";
                        else if (currentField[i][j] == 2)
                                cout << (char)2 << "|"; //if it isn't one of those, it's a player token
			//players are stored as 1 or 2, so that number is output as is
		}
		cout << endl <<"---------------\n";
	} 
}
int board::returnCols()
{
	return col; //returns the columns to the main function
}

int board::returnRows()
{
	return row; //returns rows to the main function
}
